////////////////////////////////////////////////////////////////
///// Handle making the jQuery Tools Overlay Modal for 'Flash Messages'
////  or other modals that should be loaded at page load.
/////   1. Make the Modal load at document load
//     
/////   2. Completely remove the modal element (and its children) after the user clicks
/////      to close the modal.  This prevents it from reappearing if the user clicks 
/////      the browser back button to return to the page.
//     EDIT: To handle issue #2 above, we must prevent browser caching, so I added the approp
//        method to my app_controller::beforeRender().
////////////////////////////////////////////////////////////////


// Using window load instead of document.ready to handle jquery bug when using Apple effect of jQuery tools.
//  See http://flowplayer.org/tools/overlay/apple.html

//$(window).load(function() {
//  
//  // select the overlay element - and "make it an overlay"
//  $(".modal").overlay({
//
//    // custom top position
//    top: 150,
//    
//    mask: {
//      // you might also consider a "transparent" color for the mask
//      //color: '#fff',
//      color: '#444',
//      // load mask a little faster
//      loadSpeed: 250,
//      // very transparent
//      opacity: 0.85
//    },
//    // disable this for modal dialog-type of overlays
//    closeOnClick: false,
//    // load it immediately after the construction
//    load: true
//   
//    // If I enable this effect, I get jQuery Tools inserting the image "non", with strange border, etc.
//    //  see: http://flowplayer.org/tools/forum/40/46850
//    //effect:'apple'  
//  });
//  
//  
//}); // end window load func


// switching over to document.ready in case it is faster than window.load, now that I'm not using Apple-effect
$(document).ready(function() {
  
  // select the overlay element - and "make it an overlay"
  //$(".modal").overlay({
  $(".modal.onload").overlay({

    // custom top position
    top: 150,
    
    mask: {
      // you might also consider a "transparent" color for the mask
      //color: '#fff',
      color: '#444',
      // load mask a little faster
      loadSpeed: 250,
      // very transparent
      opacity: 0.85
    },
    // disable this for modal dialog-type of overlays
    closeOnClick: false,
    // load it immediately after the construction
    load: true
   
    // If I enable this effect, I get jQuery Tools inserting the image "non", with strange border, etc.
    //  see: http://flowplayer.org/tools/forum/40/46850
    //effect:'apple'  
    
    
          //    onClose: function(event) {
          //      $(".modal").remove();
          //    }
  });
  
  //alert("Hi!!!!!!!!!!!!!");
  
}); 